<?php
include_once "../common.php";
/***********
 * <meta name="author" content="name">
 * <meta name="keywords" content="php documentation">
 * <meta name="DESCRIPTION" content="a php manual">
 * <meta name="geo.position" content="49.33;-86.59">
 * </head> <!-- parsing stops here -->
 */

if(isset($_GET['website']))
{
	$_GET['website'] = makeWebsiteFriendly($_GET['website']);
	
	if(url_exists($_GET['website']))
	{
		$tags = get_meta_tags('http://'.$_GET['website']);
		// Notice how the keys are all lowercase now, and
		// how . was replaced by _ in the key.
		
		// get webshop id(s)
		$query = "	SELECT 
						ID, Metatag
					FROM Webshops 
					WHERE Website = '".str_replace("'","",$_GET['website'])."'
						AND CustomerID = '".str_replace("'","",$_SESSION['login']['ID'])."'";
		$result = $_MySQL->runQuery($query);
		while($row = mysql_fetch_assoc($result))
		{
			if($tags['prijsgezocht'] == $row['Metatag'])
			{
				// valid url....
				$query = "UPDATE Webshops SET Status = '3' WHERE ID = '".str_replace("'","",$row['ID'])."' LIMIT 1";
				$_MySQL->runQuery($query);
				echo "succes";
				exit;
			}	
		}
		
		if(isset($tags['prijsgezocht']))
		{
			echo "De metatag code is niet juist ingevuld.\n".$tags['prijsgezocht']." staat op uw site";
		}
		else
		{
			echo "De metatag is niet aanwezig.";
		}
	}
	else
	{
		echo "De opgegeven website (".$_GET['website'].") bestaad niet\nERROR: 404";
	}
}